package com.lovo.service.impl;

import com.lovo.dto.OrderDto;
import com.lovo.dto.OrderGoodsDto;
import com.lovo.dto.TenderInfoDto;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MQService {

    @Autowired
    RabbitTemplate rabbitTemplate;

    public void sendOrder(OrderDto orderDto){
        //设置回调函数
        rabbitTemplate.setMandatory(true);

        CorrelationData correlationData=new CorrelationData("ok");
        rabbitTemplate.convertAndSend("directExchangeSell","sell.key",orderDto,correlationData);

    }
    public void sendSellGoods(List<OrderGoodsDto> goodsDtoList) {
        rabbitTemplate.setMandatory(true);
        CorrelationData correlationData = new CorrelationData("ok");
        rabbitTemplate.convertAndSend("directExchangeSellGoods", "sellgoods.key", goodsDtoList, correlationData);
    }



}
